<?php

declare (strict_types=1);

namespace app\bbxw\controller;


use think\admin\Controller;
use think\admin\helper\QueryHelper;
use app\bbxw\model\Naming as NamingMod;

/**
 * 冠名卡管理
 * @class Package
 * @package app\bbxw\controller
 */
class Naming extends Controller
{

    /**
     * 绑定数据表
     * @var string
     */
    private $table = 'customer';
    /**
     * 冠名卡管理
     * @auth true
     * @menu true
     * @login true
     */
    public function index()
    {
        $this->customer_id = input('id');
        NamingMod::mQuery()->layTable(function () {
            //$this->title = '冠名卡管理';
        }, function (QueryHelper $query) {
            $query->equal('customer_id')->like('name')->order('id asc');
        });
    }

    /**
     * 图文列表数据处理
     * @param array $data
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    protected function _index_page_filter(array &$data)
    {
    }


    /**
     * 添加冠名卡
     * @auth true
     */
    public function add()
    {
        NamingMod::mForm('form');
    }

    /**
     * 表单数据处理
     * @param array $data
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    protected function _form_filter(array &$data)
    {
        if ($this->request->isPost()) {
            $data['customer_name'] = $this->app->db->name('customer')->where(['id' => $data['customer_id']])->value('name');
        } else {
            $this->customer_id = input('customer_id');
        }

    }
    /**
     * 编辑冠名卡
     * @auth true
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function edit()
    {
        NamingMod::mForm('form');
    }


    /**
     * 删除冠名卡
     * auth true
     */
    public function remove()
    {
        NamingMod::mDelete();
    }

}